<?php
/**
 * Gialac php framework
 * URI Library
 * @package    libraries
 * @category   Storage
 * @author     Gialachoanglong
 * @copyright  (c) 2011
 */
class uri {
    /*
     * @var array $fragments
    */
    public static $fragments = array();

    /*
    * @var object $instance
    */
    private static $instance = null;

    /**
     *
     * Return URI instance
     *
     * @access public
     *
     * @return object
     *
     */
    public static function getInstance() {
        if(is_null(self::$instance)) {
            self::$instance = new uri;
        }
        return self::$instance;
    }


    /**
     *
     * @the constructor is set to private so
     * @so nobody can create a new instance using new
     *
     */
    private function __construct() {
        /*** put the string into array ***/
        self::$fragments =  explode('/',$_GET['rt']);
    }

    /**
     * @get uri fragment
     *
     * @access public
     *
     * @param string $key:The uri key
     *
     * @return string on success
     *
     * @return bool false if key is not found
     *
     */
    public function segment($key=NULL) {
        if($key==NULL) {
            return self::$fragments;
        }else {
            if(array_key_exists($key, self::$fragments)) {
                return self::$fragments[$key];
            }
            return false;
        }
    }
    private function __clone() {
    }
}

?>